-
Notifications
You must be signed in to change notification settings - Fork 172
feat(gattc): add CanSendWriteWithoutResponse for darwin #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat(gattc): add CanSendWriteWithoutResponse for darwin #386
Conversation
I think you should rebase on |
Done! Actually, |
Checking by another way than changing or writing is normally a bad practice. One reason against this is that there is a low probability that the verification will be OK, but the conditions may have changed by the time the actual call begins. In best case the called method returns an error of type "BufferFull" or whatever causing the problem and the caller can react on that, e.g. by wait and retry. Unfortunately in our case the called method "cbgo.Pheripheral.WriteCharacteristic" has no error. So, IMO, we should fix that problem at a higher level (with your PR). I assume that is what your proposal already means:
|
That makes perfect sense, however CoreBluetooth itself is being used that way. I'm not sure if it is possible to guarantee atomicity up to the driver level. |
Yes, this is not 100% possible at our side, but:
But what I really not know: what kind of problems can lead to the state "CanSendWriteWithoutResponse()==false". |
I have updated my pull request to check if we can actually send the writewithoutresponse request, otherwise returning an error. I've left the other function but we could remove it. I think that is already far better than having the call to silently fail and drop the request withtout error.
The only reason I think is that the internal queue of CoreBluetooth is full Tip canSendWriteWithoutResponse1 If this value is false, flushing all current writes sets the value to true. This also results in a call to the delegate’s peripheralIsReady(toSendWriteWithoutResponse:). Footnotes |
bluetooth/gattc_darwin.go
Lines 200 to 208 in 5c61529
We should be able to use
CanSendWriteWithoutResponse
ingattc_darwin.go
to know if we can send another write without response command.Otherwise, write without response commands are failing silently (maybe the WriteWithoutResponse command should call CanSendWriteWithoutResponse instead and fail if it returns false ?)
I'm not sure if this is relevant in other OS
Example usage: